package com.first.agent.web.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.first.agent.common.R;
import com.first.agent.service.CustomerService;
import com.first.agent.service.impl.CustomerServiceImp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created with IntelliJ IDEA.
 * User: lxm
 * Date: 2022/11/18 9:15
 * Description:
 * Version: V1.0
 */
@WebServlet("/keyWords/customerSearch")
public class keyWordsCustomerSerachServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String customer_name = req.getParameter("customer_name");
        //调用service
        CustomerService csi=new CustomerServiceImp();

        R r = csi.keyWordCustomerSearch(customer_name);

        //响应回去
        resp.setContentType("application/json;charset=utf-8");
        PrintWriter writer = resp.getWriter();
        writer.write(JSONObject.toJSONString(r));
        writer.flush();
        writer.close();

    }
}
